#include <command.h>

static uint dp_last_addr, dp_last_size;
static uint dp_last_length = 0x40;
static uint mm_last_addr, mm_last_size;

int do_mem_md(int argc, char *argv[])
{
	int size;
	int rc = 0;

	/* We use the last specified parameters, unless new ones are
	 *      * entered.
	 *           */
	addr = dp_last_addr;
	size = dp_last_size;
	length = dp_last_length;

	if (argc < 2)
		return cmd_usage(cmdtp);

	if ((flag & CMD_FLAG_REPEAT) == 0) {
		/* New command specified.  Check for a size specification.
		 *          * Defaults to long if no or incorrect specification.
		 *                   */
		if ((size = cmd_get_data_size(argv[0], 4)) < 0)
			return 1;

		/* Address is specified since argc > 1
		 *         */
		addr = simple_strtoul(argv[1], NULL, 16);
		addr += base_address;

		/* If another parameter, it is the length to display.
		 *          * Length is the number of objects, not number of bytes.
		 *                   */
		if (argc > 2)
			length = simple_strtoul(argv[2], NULL, 16);
	}

	dp_last_addr = addr;
	dp_last_length = length;
	dp_last_size = size;
	return (rc);
}

MBOOT_CMD(
		md, do_mem_md,
		"memory display",
		"[.b, .w, .l] address [# of objects]"
		);
